package com.atguigu.gulimall.order.web;

import com.atguigu.gulimall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.xml.ws.Action;
import java.util.Date;
import java.util.UUID;

/**
 * 2022/4/28 16:12 星期四
 * HelloController
 * Created by ASIA 乔帅阳 .
 * --
 * --
 */
@Controller
public class HelloController {

    @Autowired
    RabbitTemplate rabbitTemplate;
    @GetMapping("/list")
    public String listPage(){
        return "list";
    }
    @GetMapping("/pay")
    public String listPagee(){
        return "pay";
    }
    @GetMapping("/detail")
    public String listPageee(){
        return "detail";
    }


    @ResponseBody
    @GetMapping("/test/createOrder")
    public String createOrderTest(){
        //订单下单成功
        OrderEntity entity = new OrderEntity();
        entity.setOrderSn(UUID.randomUUID().toString());
        entity.setModifyTime(new Date());
        //给MQ发送消息
        rabbitTemplate.convertAndSend("order-event-exchange","order.create.order",entity);
         return "ok";
    }
}
